﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ValidationTrackingAttribute.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Used only to verify the number of times validation is invoked.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.ComponentModel.Modelling.TestAssets
{
    using System.ComponentModel.DataAnnotations;

    /// <summary>
    /// Used only to track how often validation is invoked.
    /// </summary>
    public class ValidationTrackingAttribute : ValidationAttribute
    {
        /// <summary>
        /// Tracks the number of times validation has been invoked.
        /// </summary>
        public static int ValidationCount;

        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationCount++;
            return ValidationResult.Success;
        }
    }
}